package com.szpx.litianjian.mapper;

import com.szpx.litianjian.entity.ProjectTask;
import com.szpx.litianjian.entity.StuProjectBasicInfo;
import com.szpx.litianjian.entity.ScoreInfo;
import com.szpx.litianjian.utils.pageutils.PageUtil;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectMapper {
    @Select("select t2.project_id,t3.id as stu_id,t2.class_grade,t2.class_name,\n" +
            "t3.stu_name,t2.leader_name,t1.project_name,\n" +
            "(SUM(t4.score)) / 2 as basic_score\n" +
            "from project_info t1 \n" +
            "join project_group_basic_info t2\n" +
            "on t2.project_id = t1.id\n" +
            "join student_info t3\n" +
            "on t3.id = t2.student_id\n" +
            "join student_and_score t4\n" +
            "on t4.stu_id = t3.id\n" +
            "join score t5 on t5.id = t4.score_id\n" +
            "GROUP BY t3.id")
    List<StuProjectBasicInfo> getBasicProjectInfo(PageUtil pageUtil);


    @Select("select t1.* ,t2.score\n" +
            "from score t1 \n" +
            "join student_and_score t2 \n" +
            "on t2.score_id = t1.id\n" +
            "join student_info t3 \n" +
            "on t3.id = t2.stu_id\n" +
            "where t3.id = #{stuId}")
    List<ScoreInfo> getScoreInfoByStuId(Integer stuId);


    @Select("select project_task from project_task where stu_id = #{stuId}")
    List<ProjectTask> getAllProjectTaskByStuId(Integer stuId);

}
